import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

// https://vite.dev/config/
export default defineConfig({
  plugins: [vue()],
  base: '/poem/',
  server: {
    headers: {
      'Content-Security-Policy': "img-src 'self' data: https://element-plus.org http://hdnla.asia; frame-ancestors 'self';"
    },
    allowedHosts: ["liuyuxi.cpolar.top", "hdnla.asia"],
    proxy: {
      '/api/baidu': {
        target: 'https://www.baidu.com',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api\/baidu/, '')
      },
      '/api/gushiwen': {
        target: 'https://api.gushi.ci',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api\/gushiwen/, '')
      },
      '/api/deepseek': {
        target: 'https://api.deepseek.com',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api\/deepseek/, '')
      },
      '/mock': {
        target: 'http://localhost:3001',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/mock/, '')
      }
    }
  },
  resolve: {
    alias: {
      '@': '/src'
    }
  }
})
